<template>
  <!-- 文章页面 -->
  <div class="content">
    <!-- 顶部导航栏 -->
    <!-- <div class="content_popup">
      <van-cell is-link @click="showPopup">展示弹出层</van-cell>
      <van-popup v-model="show" position="top" :style="{ height: '10%' }">
        <div class="zhihudailyOIABanner">
          <div class="zhihudaily_logo">
            <img
              src="https://static.zhihu.com/heifetz/assets/zhihuDaily.3b5756bb.png"
              alt="logo"
              width="40px"
              height="40px"
            />
          </div>
          <div class="zhihudaily_text">
            <div class="zhihudaily_title">知乎日报</div>
            <div class="zhihudaily_desc">每日提供高质量新闻资讯</div>
          </div>
          <div class="zhihudaily_botton">
            <van-button round type="info">打开&nbsp;App</van-button>
          </div>
        </div>
      </van-popup>
    </div> -->
    <!-- 主体 -->
    <div class="content_essay">
      <div v-html="detaildata.body" class="detail_text"></div>
      <div class="img_box">
        <van-image :src="detaildata.image" class="vanimage"></van-image>
        <div class="title" v-text="titledata"></div>
      </div>
    </div>
    <!-- <div icon="arrow-left" @click="gohome" width="900px" height="900px"></div> -->
    <!-- 底部导航栏 -->
    <div class="content_tabbar">
      <van-tabbar v-model="active">
        <van-tabbar-item icon="arrow-left" @click="gohome"></van-tabbar-item>
        <div class="verticalBar"></div>
        <van-tabbar-item
          icon="chat-o"
          badge="8"
          @click="gocomments()"
        ></van-tabbar-item>
        <van-tabbar-item
          icon="good-job-o"
          badge="88"
          v-if="islike"
          @click="changeislike"
          mounted
        ></van-tabbar-item>
        <van-tabbar-item
          icon="good-job"
          v-else
          @click="changeislike"
          class="islike"
          color="red"
          badge="88"
        ></van-tabbar-item>
        <van-tabbar-item
          icon="star-o"
          v-if="iscollect"
          @click="changeiscollect"
        ></van-tabbar-item>
        <van-tabbar-item
          icon="star"
          v-else
          @click="changeiscollect"
        ></van-tabbar-item>
        <van-tabbar-item
          icon="share-o"
          :options="options"
          @click="showShare = true"
        ></van-tabbar-item>
      </van-tabbar>
    </div>
    <van-share-sheet
      v-model="showShare"
      title="立即分享给好友"
      :options="options"
    />
  </div>
</template>
<script>
import { Toast } from "vant";
import "../assets/detail.css";

export default {
  data() {
    return {
      myid: "",
      detaildata: [],
      titledata: [],
      show: false,
      showShare: false,
      islike: true,
      iscollect: true,
      active: 1,
      options: [
        [
          { name: "微信", icon: "wechat" },
          { name: "朋友圈", icon: "wechat-moments" },
          { name: "微博", icon: "weibo" },
          { name: "QQ", icon: "qq" },
        ],
        [
          { name: "复制链接", icon: "link" },
          { name: "分享海报", icon: "poster" },
          { name: "二维码", icon: "qrcode" },
          { name: "小程序码", icon: "weapp-qrcode" },
        ],
      ],
    };
  },
  methods: {
    showPopup() {
      this.show = true;
    },
    onSelect(option) {
      Toast(option.name);
      this.showShare = false;
    },
    gohome() {
      this.$router.push({ name: "home" });
    },
    gocomments() {
      // let id = id;
      var twoid = this.$route.query.id
      // console.log(twoid);
      this.$router.push({ name: "Comments", query: {twoid} });
      // console.log(id);
    },
    changeislike() {
      this.islike = !this.islike;
      // this.$toast("点赞成功");
    },
    changeiscollect() {
      this.iscollect = !this.iscollect;
      // this.$toast("收藏成功");
    },
  },
  created() {
    this.myid = this.$route.query.id;
    console.log(this.myid);
    this.axios
      .get("https://apis.netstart.cn/zhihudaily/story/" + this.myid)
      .then((res) => {
        console.log(res);
        this.detaildata = res.data.story;
        // this.titledata = res.data.title
        console.log(this.detaildata);
      });
  },
};
</script>

<style lang="less" scoped>
.content {
  .content_essay {
    .detail_text {
      text-align: left;
      margin-top: 10rem;
    }
    .img_box {
      position: absolute;
      left: 0;
      top: 0;
      height: 23.5rem;
      width: 100vw;
      .vanimage {
        width: 100%;
        height: 100%;
        margin-top: -1.8rem;
      }
    }
  }
  .content_tabbar {
    width: 100vw;
    height: 3rem;
    .verticalBar {
      width: 2px;
      height: 2rem;
      background: #c4c4c4;
      display: inline-block;
      margin-top: 0.5rem;
      vertical-align: top;
      margin-right: 0.5rem;
      margin-left: 0.5rem;
    }
  }
}
</style>